package com.sun.sort.leetBook;

import org.junit.Test;

public class Test01 {
    /**
     * 输入：nums = [0,0,1,1,1,2,2,3,3,4]
     * 输出：5, nums = [0,1,2,3,4]
     * 解释：函数应该返回新的长度 5 ， 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4 。不需要考虑数组中超出新长度后面的元素。
     */
    @Test
    public void arrAyTest01(){
        int[] nums = new int[]{0,0,1,1,1,2,2,3,3,4};
        int left = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[left] != nums[i] ){
                nums[++left] = nums[i];
            }
        }
        for (int i = 0; i <= left; i++) {
            System.out.println(nums[i]);
        }
    }
    /**
     * 输入: nums = [1,2,3,4,5,6,7], k = 3
     * 输出: [5,6,7,1,2,3,4]
     * 解释:
     * 向右旋转 1 步: [7,1,2,3,4,5,6]
     * 向右旋转 2 步: [6,7,1,2,3,4,5]
     * 向右旋转 3 步: [5,6,7,1,2,3,4]
     */
    @Test
    public void arrAyTest02(){
        int[] nums = new int[]{1,2,3,4,5,6,7};
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < nums.length; j++) {
                int num = nums[j + 1];

            }
        }
    }
}
